package leetcode.easy.q100;

import leetcode.util.TreeNode;
import leetcode.util.Utils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert;

@Slf4j
public class Q {
    public static void main(String[] args) {
        log.info("res:{}",new Solution().isSameTree(Utils.buildTree(1, 2, 3, 4, 5, 6, 7, 8), Utils.buildTree(1, 2, 3, 4, 5, 6, 7, 8)));

    }


}

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 * int val;
 * TreeNode left;
 * TreeNode right;
 * TreeNode() {}
 * TreeNode(int val) { this.val = val; }
 * TreeNode(int val, TreeNode left, TreeNode right) {
 * this.val = val;
 * this.left = left;
 * this.right = right;
 * }
 * }
 */
class Solution {
    public boolean isSameTree(TreeNode p, TreeNode q) {
        if (p == null && q == null) {
            return true;
        }
        if (p != null && q != null && p.val == q.val) {
            return isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
        } else {
            return false;
        }
    }
}
